<?php

/**
 * 【单一职责原则】
 * 高内聚，低耦合
 * UserAuth负责权限验证，UserSetting负责字段修改（修改时需要校验权限）
 * Class UserAuth
 */
class UserAuth
{
    private $user;

    public function __construct($user)
    {
        $this->user = $user;
    }

    public function verify()
    {
        return true;
    }
}

class UserSetting
{
    private $user;
    private $auth;

    public function __construct($user)
    {
        $this->user = $user;
        $this->auth = new UserAuth($user);
    }

    public function changeSetting($data)
    {
        if ($this->auth->verify()) {
            //change setting
        }
    }
}